Integrand size = 13, antiderivative size = 72 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\frac {a \left (a^2+3 b^2\right ) x}{2 \left (a^2+b^2\right )^2}-\frac {b^3 \log (b \cos (x)+a \sin (x))}{\left (a^2+b^2\right )^2}-\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )} \]
[Out]
Time = 0.16 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {3587, 755, 815, 649, 209, 266} \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\frac {a x \left (a^2+3 b^2\right )}{2 \left (a^2+b^2\right )^2}-\frac {\sin ^2(x) (a \cot (x)+b)}{2 \left (a^2+b^2\right )}-\frac {b^3 \log (a \sin (x)+b \cos (x))}{\left (a^2+b^2\right )^2} \]
[In]
[Out]
Rule 209
Rule 266
Rule 649
Rule 755
Rule 815
Rule 3587
Rubi steps \begin{align*} \text {integral}& = -\frac {\text {Subst}\left (\int \frac {1}{(a+x) \left (1+\frac {x^2}{b^2}\right )^2} \, dx,x,b \cot (x)\right )}{b} \\ & = -\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )}+\frac {b \text {Subst}\left (\int \frac {-2-\frac {a^2}{b^2}-\frac {a x}{b^2}}{(a+x) \left (1+\frac {x^2}{b^2}\right )} \, dx,x,b \cot (x)\right )}{2 \left (a^2+b^2\right )} \\ & = -\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )}+\frac {b \text {Subst}\left (\int \left (-\frac {2 b^2}{\left (a^2+b^2\right ) (a+x)}+\frac {-a^3-3 a b^2+2 b^2 x}{\left (a^2+b^2\right ) \left (b^2+x^2\right )}\right ) \, dx,x,b \cot (x)\right )}{2 \left (a^2+b^2\right )} \\ & = -\frac {b^3 \log (a+b \cot (x))}{\left (a^2+b^2\right )^2}-\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )}+\frac {b \text {Subst}\left (\int \frac {-a^3-3 a b^2+2 b^2 x}{b^2+x^2} \, dx,x,b \cot (x)\right )}{2 \left (a^2+b^2\right )^2} \\ & = -\frac {b^3 \log (a+b \cot (x))}{\left (a^2+b^2\right )^2}-\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )}+\frac {b^3 \text {Subst}\left (\int \frac {x}{b^2+x^2} \, dx,x,b \cot (x)\right )}{\left (a^2+b^2\right )^2}-\frac {\left (a b \left (a^2+3 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{b^2+x^2} \, dx,x,b \cot (x)\right )}{2 \left (a^2+b^2\right )^2} \\ & = \frac {a \left (a^2+3 b^2\right ) x}{2 \left (a^2+b^2\right )^2}-\frac {b^3 \log (a+b \cot (x))}{\left (a^2+b^2\right )^2}-\frac {b^3 \log (\sin (x))}{\left (a^2+b^2\right )^2}-\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )} \\ \end{align*}
Result contains complex when optimal does not.
Time = 0.33 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.31 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\frac {2 a^3 x+6 a b^2 x-4 i b^3 x+4 i b^3 \arctan (\tan (x))+b \left (a^2+b^2\right ) \cos (2 x)-2 b^3 \log \left ((b \cos (x)+a \sin (x))^2\right )-a^3 \sin (2 x)-a b^2 \sin (2 x)}{4 \left (a^2+b^2\right )^2} \]
[In]
[Out]
Time = 0.64 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.35
method | result | size |
default | \(-\frac {b^{3} \ln \left (\tan \left (x \right ) a +b \right )}{\left (a^{2}+b^{2}\right )^{2}}+\frac {\frac {\left (-\frac {1}{2} a^{3}-\frac {1}{2} a \,b^{2}\right ) \tan \left (x \right )+\frac {a^{2} b}{2}+\frac {b^{3}}{2}}{\tan \left (x \right )^{2}+1}+\frac {b^{3} \ln \left (\tan \left (x \right )^{2}+1\right )}{2}+\frac {\left (a^{3}+3 a \,b^{2}\right ) \arctan \left (\tan \left (x \right )\right )}{2}}{\left (a^{2}+b^{2}\right )^{2}}\) | \(97\) |
risch | \(\frac {i x b}{2 i a b +a^{2}-b^{2}}+\frac {x a}{4 i a b +2 a^{2}-2 b^{2}}+\frac {i {\mathrm e}^{2 i x}}{8 i b +8 a}-\frac {i {\mathrm e}^{-2 i x}}{8 \left (-i b +a \right )}+\frac {2 i b^{3} x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {b^{3} \ln \left ({\mathrm e}^{2 i x}+\frac {i b -a}{i b +a}\right )}{a^{4}+2 a^{2} b^{2}+b^{4}}\) | \(145\) |
[In]
[Out]
none
Time = 0.29 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.31 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {b^{3} \log \left (2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}\right ) - {\left (a^{2} b + b^{3}\right )} \cos \left (x\right )^{2} + {\left (a^{3} + a b^{2}\right )} \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \]
[In]
[Out]
\[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\int \frac {\sin ^{2}{\left (x \right )}}{a + b \cot {\left (x \right )}}\, dx \]
[In]
[Out]
none
Time = 0.31 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.67 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {b^{3} \log \left (a \tan \left (x\right ) + b\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {b^{3} \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} - \frac {a \tan \left (x\right ) - b}{2 \, {\left ({\left (a^{2} + b^{2}\right )} \tan \left (x\right )^{2} + a^{2} + b^{2}\right )}} \]
[In]
[Out]
Leaf count of result is larger than twice the leaf count of optimal. 148 vs. \(2 (68) = 136\).
Time = 0.26 (sec) , antiderivative size = 148, normalized size of antiderivative = 2.06 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {a b^{3} \log \left ({\left | a \tan \left (x\right ) + b \right |}\right )}{a^{5} + 2 \, a^{3} b^{2} + a b^{4}} + \frac {b^{3} \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} - \frac {b^{3} \tan \left (x\right )^{2} + a^{3} \tan \left (x\right ) + a b^{2} \tan \left (x\right ) - a^{2} b}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} {\left (\tan \left (x\right )^{2} + 1\right )}} \]
[In]
[Out]
Time = 12.05 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.75 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx={\cos \left (x\right )}^2\,\left (\frac {b}{2\,\left (a^2+b^2\right )}-\frac {a\,\mathrm {tan}\left (x\right )}{2\,\left (a^2+b^2\right )}\right )-\frac {b^3\,\ln \left (b+a\,\mathrm {tan}\left (x\right )\right )}{{\left (a^2+b^2\right )}^2}+\frac {\ln \left (\mathrm {tan}\left (x\right )-\mathrm {i}\right )\,\left (2\,b+a\,1{}\mathrm {i}\right )}{4\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}+\frac {\ln \left (\mathrm {tan}\left (x\right )+1{}\mathrm {i}\right )\,\left (a+b\,2{}\mathrm {i}\right )}{4\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )} \]
[In]
[Out]